package net.godcode.olivenotes.entities;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "Tags")
/**
 * Tag
 * 
 * @author Chris Lewis Dec 26, 2007 <chris@thegodcode.net>
 * @version $Id: Tag.java 20 2008-01-15 07:22:45Z burningodzilla $
 */
public class Tag extends BaseModel {
	
	@Column(nullable = false)
	private String name;
	
	@ManyToMany(mappedBy = "tags")
	private Set<Post> posts = new HashSet<Post>();
	
	Tag() {}
	
	public Tag(String name) {
		this.name = name;
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	
	@Override
	public String toString() {
		return name;
	}
	
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the posts
	 */
	public Set<Post> getPosts() {
		return posts;
	}

	/**
	 * @param posts the posts to set
	 */
	public void setPosts(Set<Post> posts) {
		this.posts = posts;
	}
	
}